<!--设备类型选择组件-->

<template>
    <div class="page-box">
      <div class="page-search">
        <div>
          <label>设备编码</label>
          <el-input v-model="searchForm.MachineryTypeCode" style="width: 160px;"></el-input>
        </div>
        <div>
          <label>设备名称</label>
          <el-input v-model="searchForm.MachineryTypeName" style="width: 160px;"></el-input>
        </div>
        <div>
          <el-button type="primary" @click="search">查询</el-button>
          <el-button @click="reset">重置</el-button>
        </div>
      </div>
      <div class="page-section">
        <!--数据表格-->
        <el-table :data="tableData"  row-key="Id"   default-expand-all :tree-props="{children: 'Children', hasChildren: 'hasChildren'}"
        ref="dataForm"   v-loading="isLoading"  height="360">
          <el-table-column   type="selection" width="55"></el-table-column>
          <el-table-column prop="MachineryTypeCode" label="类型编码"  ></el-table-column>
          <el-table-column prop="MachineryTypeName" label="类型名称"  ></el-table-column>
          <el-table-column prop="Remark" label="备注"  ></el-table-column>
          <el-table-column prop="CreateTime" label="创建时间" sortable ></el-table-column>
          <el-table-column label="操作" :show-overflow-tooltip="true">
                    <template slot-scope="scope">
                        <el-button type="text" @click="Checked(scope.row)">选择</el-button>
                    </template>
                </el-table-column>
       </el-table>
  
      </div>
    </div>
  </template>
  
  <script>
  export default {
    data() {
      return {
        //搜索字段
        searchForm: {
          MachineryTypeCode: '',
          MachineryTypeName: '',
        },
       
  
        isLoading:false,
        tableData:[]
      }
    },
    mounted(){
      this.dataBind();
    },
    methods: {
      dataBind(){
        this.loading = true;
        this.$http.get('/api/MachineryType/GetAll',{
         params:{
          MachineryTypeCode:this.searchForm.MachineryTypeCode,
          MachineryTypeName:this.searchForm.MachineryTypeName,
         }
        })
        .then((res)=>{
          this.tableData = res.Data;
          this.loading = false;
        })
      },
      Checked(model){
        this.$emit('callback',model);
      },
      search(){
        this.dataBind();
      },
      reset(){
        this.searchForm.MachineryTypeCode='';
        this.searchForm.MachineryTypeName='';
      },



    }
  }
  </script>
  
  <style scoped></style>